/*
 * kl_lib_l15x.cpp
 *
 *  Created on: May 6, 2013
 *      Author: r.leonov
 */


#include "kl_lib_l15x.h"
#include <stdarg.h>
#include <string.h>
#include "tiny_sprintf.h"

Delay_t Delay;
uint32_t ITickCounter;
// ============================== Delay ================================= RJ
void Delay_t::Init(void) {
    SysTick_Config(32000000 / 8000);   // AHBFreq / SystemCoreClock = 1000 Gz;
    SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK_Div8);
}
bool Delay_t::Elapsed(uint32_t *AVar, const uint32_t ADelay) {
    if ((ITickCounter - *AVar) >= ADelay) {
        Reset(AVar); // Reset delay
        return true;
    }
    else return false;
}
// IRQ
void SysTick_Handler(void) {
    ITickCounter++;
}

